import { http } from "@/utils/http";

export interface InsertMemoTemplate {
  name: string;
  desc: string;
  memoType: number;
  suggestStrategy: number;
  memoContent: string;
  referenceOpinion: string;
  status?: number;
}

export interface UpdateMemoTemplate {
  id: number;
  name: string;
  desc: string;
  memoType: number;
  suggestStrategy: number;
  memoContent: string;
  referenceOpinion: string;
  status: number;
}

export interface RemoveMemoTemplateById {
  id: number;
}

export interface UpdateMemoTemplateStatusById {
  id: number;
  oldStatus: number;
  newStatus: number;
}

export interface QueryMemoTemplateDetailById {
  id: number;
}

export interface QueryMemoTemplate extends BizPageReq {
  name?: string;
  memoTypeEnum?: number;
  suggestStrategy?: number;
  status?: number;
  userId?: number;
}

export interface MemoTemplateVO {
  id: number;
  name: string;
  desc: string;
  memoType: number;
  memoTypeStr: string;
  suggestStrategy: number;
  suggestStrategyStr: string;
  memoContent: string;
  referenceOpinion: string;
  status: number;
  useCount: number;
  userId: number;
  isPlatform: boolean;
  createTime: string;
  updateTime: string;
}

export interface QueryMemoTemplateBaseVO {
  id: number;
  name: string;
  memoType: number;
  memoTypeStr: string;
  suggestStrategy: number;
  suggestStrategyStr: string;
  status: number;
  useCount: number;
  userId?: number;
  isPlatform: boolean;
}

export interface MemoContent {
  moduleClassifyList: [ModuleClassify];
}

export interface ModuleClassify {
  moduleName: string;
  sort: number;
  itemList: [Item];
}

export interface Item {
  itemName: string;
  sort: number;
  describe: string;
}

/** 新增备忘录模板信息 */
export const insertMemoTemplateApi = (data: InsertMemoTemplate) => {
  return http.request<BizResponse<Boolean>>(
    "post",
    "/strategy/memo/insertMemoTemplate",
    { data }
  );
};

/** 更新备忘录模板基础信息 */
export const updateMemoTemplateApi = (data: UpdateMemoTemplate) => {
  return http.request<BizResponse<Boolean>>(
    "post",
    "/strategy/memo/updateMemoTemplate",
    { data }
  );
};

/** 更新备忘录模板状态 */
export const updateMemoTemplateStatusApi = (
  data: UpdateMemoTemplateStatusById
) => {
  return http.request<BizResponse<Boolean>>(
    "post",
    "/strategy/memo/updateMemoTemplateStatusById",
    { data }
  );
};

/** 根据主键删除备忘录信息 */
export const removeMemoTemplateByIdApi = (data: RemoveMemoTemplateById) => {
  return http.request<BizResponse<Boolean>>(
    "post",
    "/strategy/memo/removeMemoTemplateById",
    { data }
  );
};

/** 根据主键查询备忘录详情信息 */
export const queryMemoTemplateByIdApi = (data: QueryMemoTemplateDetailById) => {
  return http.request<BizResponse<MemoTemplateVO>>(
    "post",
    "/strategy/memo/queryMemoTemplateById",
    { data }
  );
};

/** 多条件分页查询备忘录模板信息 */
export const queryMemoTemplateByConditionApi = (data: QueryMemoTemplate) => {
  return http.request<BizPageResponse<BizPageResult<QueryMemoTemplateBaseVO>>>(
    "post",
    "/strategy/memo/queryMemoTemplateByCondition",
    { data }
  );
};
